/**
 * Created by Fisun on 2016/11/22.
 */
$(function(){
    $.ajax({
        url:URL.getbrandtitle,
        dataType:'json',
        success:function(data){
            var data=data.result;
            console.log(data);
            callback(data)
        }
    });
    function callback(data){
       var tem='';
        for(var i=0;i<data.length;i++){
            tem += '<div>'+
                   ' <a href="mmB_brand2.html?flag='+data[i].brandTitleId+'" id="'+data[i]._id+'">'+data[i].brandTitle+''+
                   '<span class="glyphicon glyphicon-menu-down"></span>'+
                   ' </a>'+
                   ' </div>'
        }
        $("#ppai").append(tem)
    }
    //点击回到顶部
    $(".ca").on("click", function () {
        var timer =setInterval(function(){
            var leader = document.body.scrollTop;
            var target = 0;
            var step = (target-leader)/10;
            step=step>0?Math.ceil(step):Math.floor(step);
            leader=leader+step;
            if(leader==target){
                clearInterval(timer);
            }
            document.body.scrollTop = leader;
        },30);
        return false;
    })
//    箭头
    //窗口滚动动态改变火箭位置
    window.onscroll = function(){
        //滚动窗口,动态改变火箭位置
        var arrowDis = document.body.scrollTop;
        //console.log(arrowDis);
        $(".Bcj_returnArrow").css({
            transition:"all 1s",
            position:"absolute",
            right: "20/75rem",
            bottom:""+(-arrowDis)+"px"
        })
    }
//返回顶部火箭
    $(".Bcj_returnArrow").on("click",function(){
        var timer =setInterval(function(){
            var leader = document.body.scrollTop;
            var target = 0;
            var step = (target-leader)/10;
            step=step>0?Math.ceil(step):Math.floor(step);
            leader=leader+step;
            if(leader==target){
                clearInterval(timer);
            }
            document.body.scrollTop = leader;
        },15)
    })
});